package doublepoint;

/**
 * @Author: 海琳琦
 * @Date: 2022/2/3 2:20
 * https://leetcode-cn.com/problems/remove-element/
 */
public class RemoveElement {

    public int removeElement(int[] nums, int val) {
        int firstIndex = 0, endIndex = nums.length - 1;
        while (firstIndex <= endIndex) {
            if (nums[firstIndex] == val) {
                nums[firstIndex] = nums[endIndex];
                endIndex--;
            }else{
                firstIndex++;
            }
        }
        return endIndex + 1;
    }

    public static void main(String[] args) {

    }
}
